home *** CD-ROM | disk | FTP | other *** search
Text File | 1996-08-15 | 6.9 KB | 281 lines | [TEXT/ALFA] |
-
- if $startingUp {
- set tclMenu "・269"
- addMode Tcl dummyTcl {*.tcl} tclMenu
- addMenu tclMenu
- return
- }
-
-
- proc dummyTcl {} {}
- proc tclMenu {} {}
-
- # The menu.
- menu -n $tclMenu -p tclMenuProc {
- "/L<O<BloadProc"
- "/Z<O<BtraceThisProc"
- "/Z<O<UtraceTclProcノ"
- "/D<O<UdumpTraces"
- "(-"
- "rebuildTclIndices"
- "(-"
- "<U/PprocDefinition"
- "getVarValueノ"
- }
-
- newModeVar Tcl prefixString {# } 0
- newModeVar Tcl wordWrap {0} 1
- newModeVar Tcl funcExpr {^proc *([+-a-zA-Z0-9]+)} 0
- newModeVar Tcl parseExpr {^proc *([+-a-zA-Z0-9]+)} 0
- newModeVar Tcl wordBreak {(¥$)?¥w+} 0
- newModeVar Tcl wordBreakPreface {([^a-zA-Z0-9_¥$]|.¥$)} 0
- newModeVar Tcl elecLBrace 1 1
- newModeVar Tcl elecRBrace 1 1
- newModeVar Tcl elecReturn 1 1
- newModeVar Tcl autoMark 0 1
- newModeVar Tcl electricTab 1 1
- newModeVar Tcl stringColor green 0
- newModeVar Tcl commentColor red 0
- newModeVar Tcl keywordColor blue 0
-
- set tclKeyWords {
- then append array break case catch cd close concat continue elseif else eof
- error eval exec exit expr file flush foreach format for gets global glob
- history if incr info join lappend library lindex linsert list llength
- lrange lreplace lsearch lsort open pid proc puts pwd read regexp regsub
- rename return scancontext scan seek set source split string switch tell
- time trace unknown unset uplevel upvar while
-
- menu
- }
- if {[info exists Tclwords]} {set tclKeyWords [concat $tclKeyWords $Tclwords]}
- regModeKeywords -e {#} -c $TclmodeVars(commentColor) -k $TclmodeVars(keywordColor) Tcl $tclKeyWords -s $TclmodeVars(stringColor)
- unset tclKeyWords
-
-
- proc electricTclLeft {} {
- global TclmodeVars
-
- if { [isSelection] } { deleteSelection }
- if { [literalChar] } { insertText "¥{"; return }
-
- set pat {¥}[ ¥t¥r]*(else(if)?)[ ¥t¥r]*$}
- if { !$TclmodeVars(elecLBrace) || ¥
- (([lookAt [getPos]] != "¥r") && ([getPos] != [maxPos])) || ¥
- [catch {search -s -f 0 -r 1 "¥}" [getPos]} res] || ¥
- ![regexp $pat [getText [lindex $res 0] [getPos]] dum word] } {
- insertText "¥{"
- return
- }
- replaceText [lindex $res 0] [getPos] "¥} $word ¥{¥r"
- indentLine
- if { $word == "elseif" } {
- previousLine
- endOfLine
- }
- }
- bind '¥{' <s> electricTclLeft Tcl
-
-
- proc electricTclRight {} {
- global TclmodeVars
-
- if { [isSelection] } { deleteSelection }
- if { [literalChar] } { insertText "¥}"; return }
- if { !$TclmodeVars(elecRBrace) || ¥
- [regexp {[^ ¥t]} [getText [lineStart [getPos]] [getPos]]] } {
- insertText "¥}"
- blink [matchIt "¥}" [expr [getPos] - 2]]
- return
- }
- set start [lineStart [getPos]]
- insertText "¥}"
- backwardChar
- indentLine
- endOfLine
- tclCarriageReturn
- blink [matchIt "¥}" $start]
- }
- bind '¥}' <s> electricTclRight Tcl
-
-
- proc tclCarriageReturn {} {
- global TclmodeVars
-
- if { [isSelection] } { deleteSelection }
- insertText "¥r"
- if {$TclmodeVars(elecReturn)} {
- indentLine
- }
- }
- bind '¥r' tclCarriageReturn Tcl
-
-
-
-
- proc tclMenuProc {menu item} {
- global tclColoring
-
- eval $item
- }
-
-
- proc setTclMode {} {
- changeMode "Tcl"
- }
-
-
- #===============================================================================
- proc TclDblClick {from to shift option control} {
- global HOME auto_index auto_path
-
- select $from $to
- set text [getSelect]
-
- # Is it a loadable proc?
- if {[string length [set f [findCmd $text]]]} {
- editMark $f $text
- return
- }
-
- if {[info exists "auto_index($text)"]} {
- editMark "$auto_index($text)" $text
- return
- }
- # Is it a built-in Alpha command?
- set lines [grep "^・ $text " "$HOME:Help:Alpha Commands"]
- if {[string length $lines]} {
- editMark "$HOME:Help:Alpha Commands" $text
- setWinInfo read-only 1
- return
- }
- # Is it a core Tcl command?
- set lines [grep "^ $text -" "$HOME:Help:Tcl Commands"]
- if {[string length $lines]} {
- editMark "$HOME:Help:Tcl Commands" $text
- setWinInfo read-only 1
- return
- }
- # Is it a global variable?
- if {[llength [info globals [string trimleft $text {$}]]]==1} {
- showVarValue [string trimleft $text {$}]
- return
- }
- message "No docs $shift $control $option"
- }
-
- proc procDefinition {} {
- if {[llength [winNames]] && [string length [set sel [getSelect]]]} {
- set func [listpick -L $sel -p {Proc?} [lsort -ignore [info procs]]]
- } else {
- set func [listpick -p {Proc?} [lsort -ignore [info procs]]]
- }
-
- editMark [findCmd $func] $func
- }
-
- #===============================================================================
- proc TclMarkFile {} {
- set end [maxPos]
- set pos 0
- set l {}
- set markExpr {^[ ¥t]*(itcl_class|class|proc|method|body)}
- set class ""
- while {![catch {search -s -f 1 -r 1 -m 0 -i 0 "$markExpr" $pos} res]} {
- set start [lindex $res 0]
- set end [nextLineStart $start]
- set t [getText $start $end]
- switch [lindex $t 0] {
- "proc" { set text [lindex $t 1] }
- "method" { set text ${class}::[lindex $t 1] }
- "body" {
- regexp {[a-zA-Z_]+::[a-zA-Z_]+ } "[lindex $t 1] " text
- }
- "itcl_class" -
- "class" {
- set class [lindex $t 1]
- set text "${class} 000"
- }
- }
- set pos $end
- set inds($text) [lineStart [expr $start - 1]]
- }
-
- set already ""
-
- if {[info exists inds]} {
- foreach f [lsort -ignore [array names inds]] {
- set next [nextLineStart $inds($f)]
- if { [string first "000" $f] != -1 } {
- set ff "Class '[lindex $f 0]'"
- } elseif { [string first "::" $f] != -1 } {
- set ff " :: [lindex [split $f "::"] 2]"
- } else {
- set ff $f
- }
- while { [lsearch -exact $already $ff] != -1 } {
- set ff "$ff "
- }
- lappend already $ff
- setNamedMark $ff $inds($f) $next $next
- }
- }
- }
-
- proc loadProc {} {
- set pos [getPos]
- if [catch {set p [findEnclosingProc $pos] } ] {
- loadLine $pos
- } else {
- eval select $p
- uplevel ¥#0 load
- }
- goto $pos
- }
-
- # If the first brace after 'proc' ends the current line, then
- # assume the argument was a single arg with no braces.
- proc findEnclosingProc { pos } {
- set start [lindex [search -s -r 1 -f 0 {^(proc|class) } $pos] 0]
-
- # find the parameter block
- set p1 [lindex [search -s -f 1 "¥{" $start] 0]
- set p [matchIt "¥{" [expr $p1 +1]]
- if { [string trim [getText $p1 [nextLineStart $p1]]] == "¥{" } {
- if { $p < $pos } {
- error
- } else {
- return [list $start [expr $p +1]]
- }
- }
-
- # find the body
- set p [lindex [search -s -f 1 "¥{" $p] 0]
- set p [matchIt "¥{" [expr $p +1]]
- incr p
- if { $p < $pos } { error }
- return [list $start $p]
- }
-
- proc loadLine { pos } {
- goto $pos
- beginningLineSelect
- endLineSelect
- uplevel ¥#0 load
- }
-
- proc traceThisProc {} {
- global tclMenu
- # if we're tracing already then clear it
- if {[llength [traceFunc status]]>2} { traceTclProc }
-
- set p [findEnclosingProc [getPos]]
-
- set func [lindex [getText $p [nextLineStart $p]] 1]
-
- traceFunc on $func ""
- catch {markMenuItem $tclMenu {traceTclProcノ} on}
- catch {enableMenuItem $tclMenu dumpTraces on}
- message "Tracing '$func'ノ"
- }
-